#include <gtest/gtest.h>
#include <base/Foo.h>
#include <Code9.h>

struct Test9 : ::testing::Test
{
    const Foo& initWithValue(int i)
    {
        return *(new (buff) Foo(i));
    }

private:
    unsigned char buff[100];
};

TEST_F(Test9, should_keep_double_value_in_new_struct)
{
    const Foo& one = initWithValue(1);
    Double d(one);
    ASSERT_TRUE(d.getDouble() == 2);

    const Foo& two = initWithValue(2);
    ASSERT_TRUE(d.getDouble() == 2);
    Double d2(two);

    ASSERT_TRUE(d2.getDouble() == 4);
}
